﻿using System;
using System.Xml.Serialization;
using Caliburn.Micro;
using JY.Wpf.Core.Tools;
using Newtonsoft.Json;

namespace JY.Wpf.Core.Models
{
    /// <summary>
    /// Model基类
    /// </summary>
    public class ModelBase : PropertyChangedBase
    {
        #region Id——Guid Id
        private Guid _id;

        /// <summary>
        /// Id
        /// </summary>
        public Guid Id
        {
            get { return this._id; }
            set { this._id = value; base.NotifyOfPropertyChange(); }
        }
        #endregion

        #region 名称——string Name
        private string _name;
        /// <summary>
        /// 名称
        /// </summary>
        public string Name
        {
            get { return this._name; }
            set { this._name = value; base.NotifyOfPropertyChange(); }
        }
        #endregion

        #region 编号——string Number
        private string _number;
        /// <summary>
        /// 编号
        /// </summary>
        public string Number
        {
            get { return this._number; }
            set { this._number = value; base.NotifyOfPropertyChange(); }
        }
        #endregion

        #region 添加时间——DateTime AddedTime
        private DateTime _addedTime;
        /// <summary>
        /// 添加时间
        /// </summary>
        public DateTime AddedTime
        {
            get { return this._addedTime; }
            set { this._addedTime = value; base.NotifyOfPropertyChange(); }
        }
        #endregion

        #region 显示名称——string ShowName
        /// <summary>
        /// 显示名称
        /// </summary>
        [XmlIgnore]
        [JsonIgnore]
        public virtual string ShowName
        {
            get { return string.IsNullOrWhiteSpace(this.Number) ? this.Name : $"【{this.Number}】{this.Name}"; }
        }
        #endregion
    }
}
